package com.wuhao.springboot.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.wuhao.springboot.common.Result;
import com.wuhao.springboot.entity.RepairTask;
import com.wuhao.springboot.entity.dto.RepairTaskDTO;
import com.wuhao.springboot.entity.ro.PageRO;
import com.wuhao.springboot.entity.ro.RepairPageRO;
import com.wuhao.springboot.entity.vo.RepairTaskPageVO;
import com.wuhao.springboot.service.RepairTaskService;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @Description
 * @Date 2023/2/1 22:16
 * @Author pq
 */
@RestController
@RequestMapping("/repairTask")
public class RepairTaskController {

    @Resource
    private RepairTaskService repairTaskService;

    @PostMapping("/add")
    public Result add(@RequestBody RepairTask ro){
        repairTaskService.addRepairTask(ro);
        return Result.success();
    }

    @PostMapping("/update")
    public Result update(@RequestBody RepairTask ro){
        repairTaskService.updateRepairTask(ro);
        return Result.success();
    }

    @PostMapping("/delete")
    public Result delete(@RequestBody RepairTask ro){
        repairTaskService.delete(ro);
        return Result.success();
    }

    @PostMapping("/pageAll")
    public RepairTaskPageVO pageAll(@RequestBody RepairPageRO ro){
        return repairTaskService.pageAll(ro);
    }

    @PostMapping("/pageMyTask")
    public RepairTaskPageVO pageMyTask(@RequestBody RepairPageRO ro){
        return repairTaskService.pageMyTask(ro);
    }

    @PostMapping("/finish")
    public void finish(@RequestBody RepairTask ro){
         repairTaskService.finish(ro);
    }

    @PostMapping("/page")
    public Page<RepairTaskDTO> page(@RequestBody PageRO ro){
        return repairTaskService.page(ro);
    }
}
